var mySwiper = new Swiper('.swiper-container', {
    autoplay:{
        stopOnLastSilde:false
    },
    pagination : '.swiper-pagination'
});

conversion = function (id, productName, productPrice) {
    var reservationsId = $('#reservationsId').val();
    var numAcount;
    if (reservationsId == "" || reservationsId == null || reservationsId == undefined
        || reservationsId == "null" || reservationsId == "undefined") {
        Feng.success("请先登录!");
        window.location.href = Feng.ctxPath + "/integralMallWeixin/logincus";
        return false;
    }
    $.ajax({
        url: Feng.ctxPath + "/integralMallWeixin/checkPrice",
        type: "post",
        data: {
            "id": id,
            "reservationsId": reservationsId,
            "productPrice": productPrice
        },
        success: function (data) {
            if (data == -2) {
                alert("您的积分不够兑换此商品！")
            } else if (data == -1) {
                alert("库存为0，请选择其他商品！")
            } else {
                if (confirm("是否确定花费" + productPrice + "积分，兑换:" + productName + "？")) {
                    numAcount = prompt("本月最多可兑换:" + data + "张", "")
                    if (numAcount == null || numAcount == "") {
                        return false;
                    }
                    if (isNaN(numAcount)) {
                        alert("请输入数字！")
                        return false;
                    }
                    if(numAcount>data){
                        alert("最多只能兑换"+data+"张！")
                        return false;
                    }
                    $.ajax({
                        url: Feng.ctxPath + "/integralMallWeixin/conversion",
                        type: "post",
                        data: {
                            "id": id,
                            "reservationsId": reservationsId,
                            "numAcount": numAcount
                        },
                        success: function (data) {
                            if (data == 9) {
                                Feng.success("请先登录!");
                                window.location.href = Feng.ctxPath + "/integralMallWeixin/logincus";
                            } else {
                                Feng.success('操作成功!');
                                window.parent.parent.location.href = Feng.ctxPath + '/integralMallWeixin/integralRecord/' + "2";
                                parent.layer.close(parent.layer.getFrameIndex(window.name));
                            }
                        },
                        error: function (data) {
                            alert('权限被限制，请联系管理员!');
                        }
                    });
                }
            }
        }
    });
};